put the textfont of card field "sample" & "," into m
put the textsize of card field "sample" & "," after m
put the textheight of card field "sample" & "," after m
put the textalign of card field "sample" & "," after m
put the textstyle of card field "sample" after m
put m into the message box
end changecard
on check fieldname
-- check one of two fields for illegal non-digits
put 1 into i
put char 1 of card field fieldname into x
repeat until x is empty
if x is in "0123456789" then
add 1 to i
else
put empty into char i of card field fieldname
end if
put char i of card field fieldname into x
end repeat
if card field fieldname is empty then
put 1 into card field fieldname
end if
end check
on idle
-- make sure user does not enter a return or a non-digit
global oldticks
-- so idle doesn't go so often
if (the ticks - oldticks) > 240 then
put the ticks into oldticks
check("size")
check("line height")
closefield
end if
end idle
on setSample
-- set up the sample field based on the text size selected
-- use the built in textheight to set the "line height" field
set the textsize of card field "sample" to card field "size"
put the textheight of card field "sample" into card field "line height"
changecard
end setSample
on closefield
-- let the user type in any textsize they want
put the textsize of card field "sample" into x
if x <> card field "size" then
set the textsize of card field "sample" to card field "size"
put the textheight of card field "sample" into card field "line height"
changecard
else if the textheight of card field "sample" <> card field "line height" then
set the textheight of card field "sample" to card field "line height"
changecard
else -- do nothing, no changes
end if
end closefield
on hitsize
-- allow user to select a font size
put whichline(short name of target) into linenum
show card button "Hilite Size" at whereshow("font sizes",linenum)
put line linenum of card field "font sizes" into fontsize
put fontsize into card field "size"
setSample
end hitsize
on hitfonts
-- allow user to select a font name
global fonts
hide card button "Hilite Size"
put whichline(short name of target) into linenum
show card button "Hilite Name" at whereshow("font names",linenum)
put line linenum of card field "font names" into fontname
set the textfont of card field "sample" to fontname
put empty into card field "font sizes"
set the scroll of card field "font sizes" to 0
repeat with i=2 to the number of items of line linenum of fonts
put item i of line linenum of fonts into line (i-1) of card field "font sizes"
end repeat
put line 1 of card field "font sizes" into card field "size"
show card button "Hilite Size" at whereshow("font sizes",1)
setSample
end hitfonts
function whichline fieldname
-- figure out which line of a field has been clicked
return trunc(((scroll of card field fieldname) + (item 2 of the clickloc) - (item 2 of rect of card field fieldname)) div (the textheight of card field fieldname)) + 1
end whichline
function whereshow fieldname,linenum
-- figure out where line "linenum" of field "fieldname" is on screen
put the rect of card field fieldname into x
put trunc(((item 3 of x) - (item 1 of x) - 15) div 2) + (item 1 of x) into h
put trunc((linenum * (the textheight of card field fieldname)) - (the scroll of card field fieldname) - (the textheight of card field fieldname)/2) + (item 2 of x) + 1 into v
return h & "," & v
end whereshow
on hitbox
-- hit one of the style check boxes
set the hilite of the target to not the hilite of the target
put the short name of the target into addstyle
put the textstyle of card field "sample" into oldstyle
if the hilite of the target is true then
if oldstyle is "plain" then
put addstyle into newstyle
else
put addstyle & "," & oldstyle into newstyle
end if
else
put offset(addstyle,oldstyle) into x
put empty into char x to x+(length of addstyle) of oldstyle
put oldstyle into newstyle
end if
put "set the textstyle of card field " & quote & "sample" & quote & "to " & newstyle into setstyle
do setstyle
changecard
end hitbox
on hitbutton
-- handle the alignment radio buttons
global onbtn
set the hilite of card button onbtn to false
put the short name of the target into onbtn
set the hilite of card button onbtn to true
set the textalign of card field "sample" to onbtn
changecard
end hitbutton
on opencard
-- initialize the card
global onbtn,fonts
hide the message box
set the lockscreen to true
hide card button "Hilite Size"
hide card button "Hilite Name"
put empty into card field "Font sizes"
put "left" into onbtn
set the hilite of card button "left" to true
set the hilite of card button "right" to false
set the hilite of card button "center" to false
repeat with i= 6 to 12 -- turn off style check boxes
set the hilite of card button i to false
end repeat
if card field "font names" is empty then
set the cursor to 4
put fontList() into fonts
repeat with i=1 to the number of lines in fonts
put item 1 of line i of fonts into line i of card field "font names"
end repeat
end if
set the scroll of card field "font names" to 0
set the scroll of card field "Font sizes" to 0
set the textfont of card field "sample" to "geneva"
set the textstyle of card field "sample" to "plain"
set the textalign of card field "sample" to "left"
set the textsize of card field "sample" to 12
put 12 into card field "size"
put the textheight of card field "sample" into card field "line height"